import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigService;

/**
 * @Author: shaochong
 * @Date: 2020/12/21
 * @Description:
 */
public class TestSystemProperty {
    public static void main(String[] args) {

        new TestSystemProperty().getOne();
        new TestSystemProperty().getTwo();

    }

    private void getOne() {
        System.setProperty("apollo.cluster", "v-dev2");
        System.setProperty("app.id", "test01");
        System.setProperty("apollo.meta", "http://172.21.0.32:8080");
        System.setProperty("env", "dev");

        Config config = ConfigService.getConfig("routes"); //config instance is singleton for each namespace and is never null
        String someKey = "call";
        String someDefaultValue = "someDefaultValueForTheKey";
        String value = config.getProperty(someKey, someDefaultValue);
        System.out.println("value: " + value);
    }

    private void getTwo() {
        System.setProperty("apollo.cluster", "v-dev2");
        System.setProperty("app.id", "test01");
        System.setProperty("apollo.meta", "http://172.21.0.32:8080");
        System.setProperty("env", "dev");

        Config config = ConfigService.getConfig("routes"); //config instance is singleton for each namespace and is never null
        String someKey = "call";
        String someDefaultValue = "someDefaultValueForTheKey";
        String value = config.getProperty(someKey, someDefaultValue);
        System.out.println("value: " + value);
    }
}
